package com.xiaoyu.lanling.feature.newtips.datamodels

import androidx.annotation.StringDef
import com.xiaoyu.lanling.event.newtip.*
import java.util.*

object NewTipType {

    const val MAIN_CHAT_COUNT = "main_chat"
    const val MOMENT_NOTICE_COUNT = "notice_count"
    const val LIKE_NOTICE_COUNT = "like_notice"
    const val COMMENT_NOTICE_COUNT = "comment_notice"

    private val MAP = HashMap<String, String>()

    init {
        MAP[MAIN_CHAT_COUNT] = MAIN_CHAT_COUNT
        MAP[MOMENT_NOTICE_COUNT] = MOMENT_NOTICE_COUNT
        MAP[LIKE_NOTICE_COUNT] = LIKE_NOTICE_COUNT
        MAP[COMMENT_NOTICE_COUNT] = COMMENT_NOTICE_COUNT
    }

    /**
     * @return null if string not found
     */
    fun fromString(string: String?): String? {
        return MAP[string]
    }

    fun getClass(@NewTipTypeDef type: String?): Class<out NewTipBaseEvent?>? {
        var value: Class<out NewTipBaseEvent?>? = null
        when (type) {
            MAIN_CHAT_COUNT -> value = MainChatTipEvent::class.java
            MOMENT_NOTICE_COUNT -> value = MomentNoticeEvent::class.java
            LIKE_NOTICE_COUNT -> value = MomentLikeNoticeEvent::class.java
            COMMENT_NOTICE_COUNT -> value = MomentCommentNoticeEvent::class.java
        }
        return value
    }

    @StringDef(MAIN_CHAT_COUNT, MOMENT_NOTICE_COUNT, LIKE_NOTICE_COUNT, COMMENT_NOTICE_COUNT)
    annotation class NewTipTypeDef
}